package com.tools.web.work.captcha;

import com.tools.common.object.Note;

import java.util.Objects;

/**
 * 点选文字的包装实例
 * */
@Note("点选文字的包装实例")
public final class ClickChar {

    @Note("文字字符")
    private char word;

    @Note("文字字符位于验证码图片中的 X 轴坐标")
    private int x;

    @Note("文字字符位于验证码图片中的 Y 轴坐标")
    private int y;

    public ClickChar(char word, int x, int y) {
        this.word = word;
        this.x = x;
        this.y = y;
    }

    public char getWord() {
        return word;
    }

    public void setWord(char word) {
        this.word = word;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    @Override
    public String toString() {
        return "ClickChar{" +
                "word=" + word +
                ", x=" + x +
                ", y=" + y +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ClickChar clickChar = (ClickChar) o;
        if(word == clickChar.word) return true;
        if(y == clickChar.y) {
            return x == clickChar.x;
        }
        return x != clickChar.x;
    }

    @Override
    public int hashCode() {
        return Objects.hash(word, x, y);
    }
}
